﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:logic="clr-namespace:Peter.Sdw.Logic"
                    xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
                    xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
                    xmlns:view="clr-namespace:Peter.Sdw.View">
   <DataTemplate DataType="{x:Type logic:EditorMessageModel}">
      <Border Padding="4">
         <TextBlock Text="{Binding Path=Message}"
                    TextWrapping="Wrap" />
      </Border>
   </DataTemplate>
   
   <DataTemplate DataType="{x:Type logic:LightModel}">
      <view:LightView/>
   </DataTemplate>

   <DataTemplate DataType="{x:Type logic:EditorRangeModel}">
      <Border Padding="4">
         <Grid>
            <Grid.RowDefinitions>
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0"
                       Text="Create a range of items to add"
                       TextWrapping="Wrap"/>

            <TextBlock Grid.Row="1"
                       Text="Prepend"/>
            <TextBox Grid.Row="2"
                     Text="{Binding Path=RangePrepend}" />
            
            <TextBlock Grid.Row="3"
                       Text="Append" />
            <TextBox Grid.Row="4"
                     Text="{Binding Path=RangeAppend}" />

            <TextBlock Grid.Row="5"
                       Text="Range Start" />
            <controls:NumericUpDown Grid.Row="6"
                                    Precision="0"
                                    Value="{Binding Path=RangeStart}" />

            <TextBlock Grid.Row="7"
                       Text="Range End" />
            <controls:NumericUpDown Grid.Row="8"
                                    Precision="0"
                                    Value="{Binding Path=RangeEnd}" />
         </Grid>
      </Border>
   </DataTemplate>

   <DataTemplate DataType="{x:Type logic:EditorAddModel}">
      <Border Padding="4">
         <Button Width="150"
                 HorizontalAlignment="Center"
                 Command="{Binding Path=AddCommand}">
            <StackPanel Orientation="Horizontal">
               <icons:IconDisplay Icon="PlusSign" />
               <TextBlock Text="Add List"
                          Margin="4,0,0,0" />
            </StackPanel>
         </Button>
      </Border>
   </DataTemplate>

   <DataTemplate DataType="{x:Type logic:EditorEditEntriesModel}">
      <Grid Margin="4"
            Width="200">
         <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
         </Grid.RowDefinitions>
         <TextBlock Text="Passages to add"
                    Grid.Row="0" />
         <TextBox Grid.Row="1"
                  Text="{Binding Path=TextToFormat}"
                  VerticalScrollBarVisibility="Auto"
                  TextWrapping="WrapWithOverflow"
                  VerticalAlignment="Stretch"
                  AcceptsReturn="True"
                  Margin="0,0,0,5" />

         <GroupBox Grid.Row="2"
                   Header="Remove from Text">
            <Grid>
               <Grid.RowDefinitions>
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
               </Grid.RowDefinitions>
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="*" />
               </Grid.ColumnDefinitions>
               <ListBox ItemsSource="{Binding Path=Removes}"
                        SelectedItem="{Binding Path=SelectedRemove}"
                        Grid.ColumnSpan="2"
                        Grid.Column="0"
                        Grid.Row="0">
                  <ListBox.ItemTemplate>
                     <DataTemplate>
                        <TextBox Text="{Binding Path=Text}"
                                 HorizontalAlignment="Stretch"
                                 TextWrapping="Wrap"
                                 Margin="4,2"/>
                     </DataTemplate>
                  </ListBox.ItemTemplate>
               </ListBox>
               <Button Grid.Row="1"
                       Grid.Column="0"
                       CommandParameter="del"
                       Command="{Binding Path=RemoveCommand}">
                  <icons:IconDisplay Icon="Remove" />
               </Button>
               <Button Grid.Row="1"
                       Grid.Column="1"
                       CommandParameter="add"
                       Command="{Binding Path=RemoveCommand}">
                  <icons:IconDisplay Icon="PlusSign" />
               </Button>
            </Grid>
         </GroupBox>

         <GroupBox Header="Convert"
                   Grid.Row="3">
            <Grid>
               <Grid.RowDefinitions>
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
               </Grid.RowDefinitions>
               <RadioButton GroupName="convert"
                            IsChecked="{Binding Path=NoConvert}"
                            Grid.Row="0">No conversion</RadioButton>
               <RadioButton GroupName="convert"
                            IsChecked="{Binding Path=LineConvert}"
                            Grid.Row="1">Each line is an Entry</RadioButton>
               <RadioButton GroupName="convert"
                            x:Name="SpaceConvert"
                            IsChecked="{Binding Path=SpaceConvert}"
                            Grid.Row="2">Make new lines spaces</RadioButton>
               <CheckBox Grid.Row="3"
                         IsChecked="{Binding Path=KeepEmptyLines}"
                         IsEnabled="{Binding ElementName=SpaceConvert, Path=IsChecked}"
                         Margin="20,0,0,0">Keep Empty Lines</CheckBox>
               <RadioButton GroupName="convert"
                            x:Name="ConvertRegex"
                            IsChecked="{Binding Path=RegexConvert}"
                            Grid.Row="4">Use this Regular Expression:</RadioButton>
               <TextBox Grid.Row="5"
                        Text="{Binding Path=ConvertRegex}"
                        IsEnabled="{Binding ElementName=ConvertRegex, Path=IsChecked}"/>
            </Grid>

         </GroupBox>

         <Button Grid.Row="4"
                 Margin="0,5,0,0"
                 Command="{Binding Path=AddCommand}">
            <StackPanel Orientation="Horizontal">
               <icons:IconDisplay Icon="PlusSign" />
               <TextBlock Text="Add Entries"
                          Margin="4,0,0,0" />
            </StackPanel>
         </Button>
      </Grid>
   </DataTemplate>
</ResourceDictionary>
